#include <iostream>
using namespace std;
int book[1001],sum,n,e[1001][1001];
void dfs(int cur){
	cout<<cur<<endl;
	sum++;
	if(sum==n)return;
	for(int i=1;i<=n;i++){
		if(book[i]==0 && e[cur][i]==1){
			book[i]=1;
			dfs(i);			
		}
	}
	return;
}
int main() {
	int n,m,i,j;
   cin>>n>>m;
   for(i=1;i<=n;i++)
   		for(j=1;j<=m;j++){
		   	if(i==j)e[i][j]=0;
		   	else e[i][j]=9999;
		   }
	for(i=1;i<=m;i++){
		int a,b;
		cin>>a>>b;
		e[a][b]=1;
		e[b][a]=1;
	}
	book[1]=1;
	dfs(1);
   
    return 0;
}


